import request from "@/axios.js";
import {absoluteRoot, baseUrl} from "@/config/env";

const defaultConfig = {
    currentRootUrl: absoluteRoot,
    contextPath: baseUrl
}

export function createDocument(data) {
    return request({
            url: baseUrl + '/startOfficeApi/createDocument',
            method: 'post',
            data: data,
        }
    )
}

export function getDocumentConfig(documentId, documentModel) {
    let data=Object.assign({},defaultConfig,documentModel)
    return request({
            url: baseUrl + '/startOfficeApi/getDocumentConfig',
            method: 'post',
            data: data
        }
    )
}

export function getDocumentConfigByOssId(ossId, documentModel) {
    let data=Object.assign({},defaultConfig,documentModel)
    return request({
            url: baseUrl + '/startOfficeApi/getDocumentConfigByOssId/' + ossId,
            method: 'post',
            data: data
        }
    )
}

export function getDocumentConfigByOssUrl(ossUrl, documentModel) {
    let data=Object.assign({},defaultConfig,documentModel)
    return request({
            url: baseUrl + '/startOfficeApi/getDocumentConfigByOssUrl/' + ossUrl,
            method: 'post',
            params: {ossUrl: ossUrl},
            data: data
        }
    )
}

const startOfficeApi = {
    createDocument,
    getDocumentConfig,
    getDocumentConfigByOssId,
    getDocumentConfigByOssUrl,

}
export default startOfficeApi;
